<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>

<html>
    <head>
		<%@ include file="/WEB-INF/views/include/common.jsp" %>
		<meta name="AUTHOR" content="QroTech Inc." />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="CACHE-CONTROL" content="NO-CACHE">
		<meta http-equiv="PRAGMA" content="NO-CACHE">
		<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<title>큐로넷::위치관제시스템</title>
		
		<link rel="stylesheet" href="${cssUrl}/header-1.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/fancy_table.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/menu.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/table.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/button.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/secondmenu.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/body.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/Qronet_display_sub4.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/m-400.css" type="text/css" />
		
		<script src="${jsUrl}/pagenation.js"></script>
		<script src="${jsUrl}/windowSize.js"></script>
		<script src="${jsUrl}/m-410.js"></script>
		
		
		
		
    </head>
    <body onload="init();">
    	<div class="headerContent">
	
		<div class="pageHeader">
			<%@ include file="/WEB-INF/views/include/logoLink.jsp" %>
			<div id="pageNav">
				<ul>
				<%@ include file="/WEB-INF/views/include/mainNaviStyle2.jsp" %>
					<!-- <a href="m-100.html" class="togglerHeader"><li class="hmenu0" id="hdmenu0"></li></a>
					<a href="#" class="togglerHeader"><li class="hmenu1" id="hdmenu1"></li></a>
					<a href="m-300.html" class="togglerHeader"><li class="hmenu2" id="hdmenu2"></li></a>
					<a href="m-400.html" class="togglerHeader"><li class="hmenu3" id="hdmenu3"></li></a>
					<a href="m-500.html" class="togglerHeader"><li class="hmenu4" id="hdmenu4"></li></a> -->
				</ul>
			</div>
			<div id="pageNavRight">
				<%@ include file="/WEB-INF/views/include/titleLink.jsp" %>
			</div>
		</div>
			<div class="header_line"></div>
		</div><!--header end-->	
		<div class="secondMenu" >
			<div id="menu">
				<%@ include file="/WEB-INF/views/include/m400innerNavi.jsp" %>
			</div>
		</div><!-- second menu end -->
        
        	
		
		<div class="mainContent">	
			<div class="searchInfo">
					<ul>
						<li class= "locationInfo"><span>Q &amp; A</span></li>
					</ul>
					<div class="last"><a onclick="javscript:openQuestionPopup('http://www.qronet.co.kr/help/qronet_help.html#MonitoringArea')"><img src="${imgUrl}/question_mark.png"></a></div>
			</div><!-- searchInfo end -->	
	        <div class="m400">
	        	<div class="info_text">
					<img src="${imgUrl}/info_qna.png">
			     </div>
	        	<div class="sub4_1_content">
    				<div class="table_wrapper">
    					<div style="padding:30px 0;">
			        		<a onClick="goWrite()" class="button1 add-button1 ">새글 등록</a>
			        	</div >
    					<table class="sub4_table" cellpadding="0" cellspacing="0" id="boardList">
    					<thead>
    						<tr>
    							<th width="50px">번호</th>
    							<th width="380px">제목</th>
    							<th width="80px">작성자</th>
    							<th width="80px">날짜</th>
    							<th width="70px">조회수</th>
    						</tr>
    					</thead>
    					<tbody>
    						<tr style="cursor:pointer;" onClick="gotoNoticeView(this)">
    							<td id="seq"></td>
    							<td id="title" class="left_align"></td>
    							<td id="writer"></td>
    							<td id="regiTime"></td>
    							<td id="viewCnt"></td>
    							<td style="display:none"><input type="hidden" id="textID"/>
    													 <input type="hidden" id="replyNum"/></td>
    						</tr>
    						<%-- <tr>
    							<td>10</td>
    							<td class="left_align"><a href="m-411.html">궁그한 점이 있어 질문 드립니다.</a></td>
    							<td>큐로넷</td>
    							<td>2013.02.07</td>
    							<td>1000</td>
    						</tr>
    						<tr>
    							<td>10</td>
    							<td class="left_align"><a href="m-411.html"><span class="response"><img src="${imgUrl}/resp_arrow.png" style="vertical-align: top;"> RE </span>궁그한 점이 있어 질문 드립니다.</a></td>
    							<td>큐로넷</td>
    							<td>2013.02.07</td>
    							<td>1000</td>
    						</tr> --%>
    					</tbody>
    				</table>
    				
    				</div>
    				
    				<div class="pagenation" id="pagenation"> 
    				</div>
    			</div>
	        </div>	
        	
		</div> <!-- mainContent end -->
		
		<div class="chart_footer">
		    <div class="footerCenter">
		       <span>Copyright ⓒ 2013 Qrotech Co.,Ltd. All rights reserved.</span>
		    </div>
	 </div>	<!-- footer end-->	
	 <form id="theForm" name="theForm" action="" method="post" style="display:none;">
		<input type="hidden" name="textID" id="paramTextID"/>
		<input type="hidden" name="seq" id="paramSeq"/>
	</form>
	<script language="javascript">
	  var _this = this;
	    var markerSetting = {
	    		paging:{}
	    }
	    function init() {
	    	markerSetting.paging.page = '<c:out value="${totalPage.page}"/>';
			markerSetting.paging.totalPage ='<c:out value="${totalPage.totalPage}"/>';
			markerSetting.paging.nowSeq = 1;
			
			getBoardList();
	    }
	    
	    function getBoardList() {
	    	_this.boardList = tableSync('boardList');
	    	var url='helperQnaList.json';
	    	
			var param=markerSetting.paging;
			
			AjaxPost(url, param, function(data){
//	 	 		jsonLog(data.boardList);
				$.each(data.boardList,function(index, value){
					value.regiTime = formatter.dateFormatYYYYMMDD(new Date(value.regiTime));
				});
				_this.boardList.tableAutoSync(data.boardList);
				markerSetting.paging.totalPage= data.totalPage.totalPage;
				makePaging();
				showTitleRe();
			});
	    }
	    function showTitleRe() {
			
			$("#boardList > tbody > tr").each(function() {
				var title = $(this).find("#title").text();
				if($(this).find("#replyNum").val() != 0) {
					$(this).find("#title").html("<span class='response'><img src='/resources/images/resp_arrow.png' style='vertical-align: top;'> RE </span>"+$(this).find("#title").text());
				}	
			});
		}
	    function makePaging() {
	    	$('#pagenation').html("");
			var totalPage = markerSetting.paging.totalPage;
			var nowPage = markerSetting.paging.page;
			var html='';
			var setFunctionName='';
			var index=(nowPage-10);
			var indexCount=0;
			
			var endPage = totalPage / 10;
			if (totalPage % 10 > 0) {
				endPage = endPage + 1;
			}
			if(index>1){
				html+='<a onclick="changePaging('+index+',\'before\''+')"><img src="${imgUrl }/QronetHomeImages/page_left_arrow.png"/></a>';
			}
//	 		//logs('totalPage/20 = '+totalPage/20);
			for(;index<=endPage;index++){
				if((index)==nowPage){
					setFunctionName='';
				}else{
					setFunctionName=' onclick="changePaging('+index+')"';
				}
				
				if(index>0){
						
					html+='<a '+setFunctionName+'>'+index+'</a>';	
					
					indexCount++;
				}
				if(indexCount>9){
					html+='<a onclick="changePaging('+index+',\'after\''+')"><img src="${imgUrl }/QronetHomeImages/page_right_arrow.png"/></a>';
					break;
				}
				
			}
			$('#pagenation').html(html);
	    }
	    
	    function changePaging(index, option){
			logs('markerSetting.paging.totalPage = '+markerSetting.paging.totalPage);
			if(option==null){
				logs(', index = '+index);
				
				markerSetting.paging.page=index;
				markerSetting.paging.start=0;
				markerSetting.paging.end=0;
				getBoardList();
			}else{
				if(option=='before'){
					var next = index-9;
					while(next<=0){
						next++;
					}
					logs('next = '+next+', index = '+index);
					markerSetting.paging.page=next;
					markerSetting.paging.start=0;
					markerSetting.paging.end=0;
					getBoardList();
				}else if(option=='after'){
					var next = index+9;
					while(next>=(markerSetting.paging.totalPage/10)+1){
						next--;
					}
					logs('next = '+next+', index = '+index);
					markerSetting.paging.page=next;
					markerSetting.paging.start=0;
					markerSetting.paging.end=0;
					getBoardList();
				}
			}
		}
	    
	    function gotoNoticeView(tr){
	    	var textID = $(tr).find("#textID").val();
	    	$("#paramTextID").val(textID);
			$("#paramSeq").val($(tr).find("#seq").text());
	    	$("#theForm").attr("action", "/helper/helperQnaView");
	    	$("#theForm").submit();
	    }
	    function goWrite() {
	    	window.open('/admin/adminBoardWrite?boardType=2&mode=insert&isHelp=y','','width=660px,height=770px,scrollbars=yes');
	    }
	</script>
  </body>
</html>
